//package org.iks.push.server;
//
//import io.netty.bootstrap.ServerBootstrap;
//import io.netty.channel.ChannelInitializer;
//import io.netty.channel.ChannelPipeline;
//import io.netty.channel.nio.NioEventLoopGroup;
//import io.netty.channel.socket.SocketChannel;
//import io.netty.channel.socket.nio.NioServerSocketChannel;
//import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
//import org.iks.push.codec.MessageCodec;
//import org.iks.push.handler.AuthVerifyHandler;
//import org.iks.push.handler.ChannelAuthInterceptor;
//import org.iks.push.handler.ChatMessageHandler;
//import org.springframework.beans.factory.DisposableBean;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.stereotype.Service;
//
///**
// * @author kzou
// * @date 2023/11/9 20:40
// * @description: custom im server
// */
//@Service
//public class PushServer implements CommandLineRunner, DisposableBean {
//
//    private  final String path = "/ws";
//
//    NioEventLoopGroup bossGroup = new NioEventLoopGroup();
//    NioEventLoopGroup workerGroup = new NioEventLoopGroup();
//
//    @Override
//    public void run(String... args) {
//        ServerBootstrap serverBootstrap = new ServerBootstrap()
//                .group(bossGroup, workerGroup)
//                .channel(NioServerSocketChannel.class)
//                .childHandler(new ChannelInitializer<SocketChannel>() {
//                    @Override
//                    protected void initChannel(SocketChannel channel) {
//                        ChannelPipeline pipeline = channel.pipeline();
//                        pipeline
//                                .addLast(new LengthFieldBasedFrameDecoder(
//                                        1024, 8, 4, 0, 0
//                                ))
//                                .addLast(new MessageCodec())
//                                .addLast(new AuthVerifyHandler())
//                                .addLast(new ChannelAuthInterceptor())
//                                .addLast(new ChatMessageHandler());
//                    }
//                });
//        int port = 8015;
//        serverBootstrap.bind(port);
//    }
//
//    @Override
//    public void destroy() {
//        workerGroup.shutdownGracefully();
//        bossGroup.shutdownGracefully();
//    }
//}
